package com.zf.bm.common.core.sys.web;


import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.zf.bm.common.constant.Constant;
import com.zf.bm.common.core.log.annotation.SysLog;
import com.zf.bm.common.core.sys.entity.Citycode;
import com.zf.bm.common.core.sys.entity.Dict;
import com.zf.bm.common.core.sys.service.CitycodeService;
import com.zf.bm.common.core.sys.service.OperateTypeService;
import com.zf.bm.common.core.sys.utils.DictUtils;
import com.zf.bm.common.core.sys.utils.SysUtils;
import com.zf.bm.common.utils.CacheUtils;
import com.zf.bm.common.web.BaseController;
import com.zf.bm.modules.alarm.service.*;
import com.zf.bm.modules.detector.entity.ComDetectorDevice;
import com.zf.bm.modules.detector.entity.TblGroupInfo;
import com.zf.bm.modules.detector.service.ComDetectorDeviceService;
import com.zf.bm.modules.detector.service.TblGroupInfoService;
import com.zf.bm.modules.policy.service.AlarmRecorderService;
import com.zf.bm.modules.policy.service.AlarmReportRecordService;
import com.zf.bm.modules.policy.util.PolicyUtils;
import com.zf.bm.modules.policy.util.TreeUtils;
import com.zf.bm.modules.system.entity.SysDict;
import com.zf.bm.modules.system.entity.SysInfo;
import com.zf.bm.modules.system.service.SysDictService;
import com.zf.bm.modules.system.service.SysInfoService;
import com.zf.bm.vo.*;
import com.zf.common.constant.ModuleConstant;
import com.zf.common.enums.*;
import com.zf.common.factory.OperateTypeFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.*;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

@RestController
@RequestMapping(value = "${adminPath}/sys/publicData", method = {RequestMethod.GET, RequestMethod.POST})
public class PublicDataController extends BaseController {
    @Autowired
    private OperateTypeService operateTypeService;

    @Autowired
    private CitycodeService citycodeService;

    @Autowired
    private AlarmRecorderService alarmRecorderService;

    @Autowired
    private TblGroupInfoService tblGroupInfoService;

    @Autowired
    private JedisUtil jedisUtil;

    @Autowired
    private ComDetectorDeviceService comDetectorDeviceService;

    @Autowired
    private SysInfoService sysInfoService;

    @Autowired
    AlarmReportRecordService AlarmReportRecordService;
    @Autowired
    private SysDictService sysDictService;

    @Autowired
    AAlarmNetLogV2Service aAlarmNetLogV2Service;

    @Autowired
    AAlarmAppBehaviorEmailV2Service aAlarmAppBehaviorEmailV2Service;

    @Autowired
    AAlarmAppBehaviorWebV2Service aAlarmAppBehaviorWebV2Service;

    @Autowired
    AAlarmAppBehaviorFileTransportV2Service aAlarmAppBehaviorFileTransportV2Service;

    @Autowired
    AAlarmAppBehaviorSslV2Service aAlarmAppBehaviorSslV2Service;

    @Autowired
    AAlarmAppBehaviorDnsV2Service aAlarmAppBehaviorDnsV2Service;

    @Autowired
    AAlarmAppBehaviorDbOperateV2Service aAlarmAppBehaviorDbOperateV2Service;

    @Autowired
    AAlarmAppBehaviorLoginV2Service aAlarmAppBehaviorLoginV2Service;

    @Autowired
    AAlarmAppBehaviorControlV2Service aAlarmAppBehaviorControlV2Service;
    @Resource
    private OperateTypeFactory operateTypeFactory;


    
    private static final String TYPE = "type";
    private static final String ALARM_POLICY_TYPE = "alarmPolicyType";


    /**
     * 获取操作类型列表
     *
     * @return
     */
    @SysLog("获取操作类型列表")
    @RequestMapping(value = "operation")
    public Result getOperation() {
        QueryWrapper<OperateType> operationQueryWrapper = new QueryWrapper<>();
        operationQueryWrapper.eq(Constant.OPT_TYPE, 1);
        List<OperateType> operationList = operateTypeService.list(operationQueryWrapper);
        return new Result(SysUtils.boxListResult(operationList));
    }

    /**
     * 获取操作状态列表
     *
     * @return
     */
    @SysLog("获取操作状态列表")
    @RequestMapping(value = "optRet")
    public Result getOptRet() {
        QueryWrapper<OperateType> optRetQueryWrapper = new QueryWrapper<>();
        optRetQueryWrapper.eq(Constant.OPT_TYPE, 2);
        List<OperateType> optRetList = operateTypeService.list(optRetQueryWrapper);
        return new Result(SysUtils.boxListResult(optRetList));
    }

    /**
     * 获取文件方向列表
     *
     * @return
     */
    @SysLog("获取文件方向列表")
    @RequestMapping(value = "direction")
    public Result getDirection() {
        QueryWrapper<OperateType> directionQueryWrapper = new QueryWrapper<>();
        directionQueryWrapper.eq(Constant.OPT_TYPE, 3);
        List<OperateType> directionList = operateTypeService.list(directionQueryWrapper);
        return new Result(SysUtils.boxListResult(directionList));
    }

    @RequestMapping(value = "appType")
    public Result getAppType() {
        Map<String, String> appTypeMap = new HashMap<>();
        List<Map<String, String>> list = new ArrayList<>();
        appTypeMap.put(Constant.VALUE, "1");
        appTypeMap.put(Constant.LABEL, "HTTP");
        list.add(appTypeMap);
        Map<String, String> appTypeMap1 = new HashMap<>();
        appTypeMap1.put(Constant.VALUE, "2");
        appTypeMap1.put(Constant.LABEL, "邮件传输");
        list.add(appTypeMap1);
        Map<String, String> appTypeMap2 = new HashMap<>();
        appTypeMap2.put(Constant.VALUE, "3");
        appTypeMap2.put(Constant.LABEL, "远程访问");
        list.add(appTypeMap2);
        Map<String, String> appTypeMap3 = new HashMap<>();
        appTypeMap3.put(Constant.VALUE, "4");
        appTypeMap3.put(Constant.LABEL, "文件传输");
        list.add(appTypeMap3);
        Map<String, String> appTypeMap4 = new HashMap<>();
        appTypeMap4.put(Constant.VALUE, "5");
        appTypeMap4.put(Constant.LABEL, "即时通信");
        list.add(appTypeMap4);
        Map<String, String> appTypeMap5 = new HashMap<>();
        appTypeMap5.put(Constant.VALUE, "6");
        appTypeMap5.put(Constant.LABEL, "其他协议");
        list.add(appTypeMap5);
        return new Result(list);
    }

    @RequestMapping(value = "riskRank")
    public Result getRiskRank() {
        Map<String, String> riskRankMap = new HashMap<>();
        List<Map<String, String>> list = new ArrayList<>();
        riskRankMap.put(Constant.VALUE, "1");
        riskRankMap.put(Constant.LABEL, "特别重大事件");
        list.add(riskRankMap);
        Map<String, String> riskRankMap1 = new HashMap<>();
        riskRankMap1.put(Constant.VALUE, "2");
        riskRankMap1.put(Constant.LABEL, "重大事件");
        list.add(riskRankMap1);
        Map<String, String> riskRankMap2 = new HashMap<>();
        riskRankMap2.put(Constant.VALUE, "3");
        riskRankMap2.put(Constant.LABEL, "较大事件");
        list.add(riskRankMap2);
        Map<String, String> riskRankMap3 = new HashMap<>();
        riskRankMap3.put(Constant.VALUE, "4");
        riskRankMap3.put(Constant.LABEL, "一般事件");
        list.add(riskRankMap3);
        Map<String, String> riskRankMap4 = new HashMap<>();
        riskRankMap4.put(Constant.VALUE, "5");
        riskRankMap4.put(Constant.LABEL, "无风险事件");
        list.add(riskRankMap4);
        return new Result(list);
    }

    @RequestMapping(value = "eventType")
    public Result getEventType() {
        Map<String, String> eventTypeMap = new HashMap<>();
        List<Map<String, String>> list = new ArrayList<>();
        eventTypeMap.put(Constant.VALUE, "1");
        eventTypeMap.put(Constant.LABEL, "有害程序");
        list.add(eventTypeMap);
        Map<String, String> eventTypeMap1 = new HashMap<>();
        eventTypeMap1.put(Constant.VALUE, "2");
        eventTypeMap1.put(Constant.LABEL, "网络攻击");
        list.add(eventTypeMap1);
        Map<String, String> eventTypeMap2 = new HashMap<>();
        eventTypeMap2.put(Constant.VALUE, "3");
        eventTypeMap2.put(Constant.LABEL, "信息破坏");
        list.add(eventTypeMap2);
        Map<String, String> eventTypeMap3 = new HashMap<>();
        eventTypeMap3.put(Constant.VALUE, "4");
        eventTypeMap3.put(Constant.LABEL, "信息内容安全");
        list.add(eventTypeMap3);
        Map<String, String> eventTypeMap4 = new HashMap<>();
        eventTypeMap4.put(Constant.VALUE, "5");
        eventTypeMap4.put(Constant.LABEL, "设备设施故障");
        list.add(eventTypeMap4);
        Map<String, String> eventTypeMap5 = new HashMap<>();
        eventTypeMap5.put(Constant.VALUE, "6");
        eventTypeMap5.put(Constant.LABEL, "灾害性事件");
        list.add(eventTypeMap5);
        Map<String, String> eventTypeMap6 = new HashMap<>();
        eventTypeMap6.put(Constant.VALUE, "7");
        eventTypeMap6.put(Constant.LABEL, "其他安全事件");
        list.add(eventTypeMap6);
        return new Result(list);
    }

    @SysLog("获取统计报表树")
    @RequestMapping(value = "getReportTree")
    public Result getReportTree(){
        //无数据字典功能,根据系统以往设计采用编程实现树
        TreeVo firTree = new TreeVo();
        firTree.setId("01");
        firTree.setValue("全部报表");
        firTree.setTreeIndex(0);

        List<TreeVo> secTreeList = new ArrayList<>();

        //设备状态报表
        List<TreeVo> ThrTreeList1 = new ArrayList<>();
        TreeVo secTree1 = new TreeVo();
        secTree1.setId("11");
        secTree1.setValue("设备状态报表");
        secTree1.setTreeIndex(1);
        TreeVo thrTree1 = new TreeVo();
        thrTree1.setId("1");
        thrTree1.setValue("审计代理状态");
        thrTree1.setTreeIndex(2);
        ThrTreeList1.add(thrTree1);
        secTree1.setChildren(ThrTreeList1);

        //网络运行报表
        List<TreeVo> ThrTreeList2 = new ArrayList<>();
        TreeVo secTree2 = new TreeVo();
        secTree2.setId("12");
        secTree2.setValue("网络运行报表");
        secTree2.setTreeIndex(1);
        TreeVo thrTree3 = new TreeVo();
        thrTree3.setId("3");
        thrTree3.setValue("审计代理网络状态");
        thrTree3.setTreeIndex(2);
        ThrTreeList2.add(thrTree3);
        secTree2.setChildren(ThrTreeList2);

        //业务报表
        List<TreeVo> ThrTreeList3 = new ArrayList<>();
        TreeVo secTree3 = new TreeVo();
        secTree3.setId("13");
        secTree3.setValue("业务报表");
        secTree3.setTreeIndex(1);
        TreeVo thrTree4 = new TreeVo();
        thrTree4.setId("4");
        thrTree4.setValue("行为审计报表");
        thrTree4.setTreeIndex(2);
        TreeVo thrTree5 = new TreeVo();
        thrTree5.setId("5");
        thrTree5.setValue("流量审计报表");
        thrTree5.setTreeIndex(2);
        TreeVo thrTree6 = new TreeVo();
        thrTree6.setId("6");
        thrTree6.setValue("事件报表");
        thrTree6.setTreeIndex(2);
        ThrTreeList3.add(thrTree4);
        ThrTreeList3.add(thrTree5);
        ThrTreeList3.add(thrTree6);
        secTree3.setChildren(ThrTreeList3);


        //告警报表
        List<TreeVo> ThrTreeList4 = new ArrayList<>();
        TreeVo secTree4 = new TreeVo();
        secTree4.setId("14");
        secTree4.setValue("告警报表");
        secTree4.setTreeIndex(1);
        TreeVo thrTree7 = new TreeVo();
        thrTree7.setId("7");
        thrTree7.setValue("告警报表");
        thrTree7.setTreeIndex(2);
        ThrTreeList4.add(thrTree7);
        secTree4.setChildren(ThrTreeList4);

        secTreeList.add(secTree1);
        secTreeList.add(secTree2);
        secTreeList.add(secTree3);
        secTreeList.add(secTree4);
        firTree.setChildren(secTreeList);

        return new Result(firTree);
    }

    /**
     * 查询类型列表
     *
     * @return
     */
    @RequestMapping(value = "selectTypeList")
    public Result selectTypeList(@RequestBody TypeVo typeVo) {
        String[] typeArray = typeVo.getType();
        Map<String, List<?>> resultMap = Maps.newHashMap();
        for (String type : typeArray) {
            resultMap.put(type, getDataByType(type));
        }
        return new Result(resultMap);
    }

    @SysLog("查询类型列表")
    @RequestMapping(value = "selectNumberTypeList")
    public Result selectNumberTypeList(@RequestBody TypeVo typeVo) {
        String[] typeArray = typeVo.getType();
        Map<String, List<?>> resultMap = Maps.newHashMap();
        for (String type : typeArray) {
            //查看label的值是不是number，如果是number，转换成number
            List<?> typeList = getDataByType(type);
            typeList = convertToNumber(typeList);
            resultMap.put(type, typeList);
        }
        return new Result(resultMap);
    }

    /**
     * 如果值是数字，转换成数字
     * @param typeList
     * @return
     */
    private List<?> convertToNumber(List<?> typeList) {
        JSONArray jsonArray = JSONArray.parseArray( JSONArray.toJSONString(typeList));

        boolean number = true;
        for (Object o: jsonArray
             ) {
            String v =  ((Map)o).get(Constant.VALUE).toString();
            Pattern pattern = Pattern.compile("^[-\\+]?[\\d]*$");
            if(!pattern.matcher(v).matches())
            {
                number = false;
            }
        }

        List<Map<String,Object>> resultList = new LinkedList<>();
        if(number){
            for (Object o: jsonArray
            ) {
                Map<String,Object> map = new HashMap<>();
                map.put(Constant.VALUE,Integer.parseInt(((Map)o).get(Constant.VALUE).toString()));
                map.put(Constant.LABEL,((Map)o).get(Constant.LABEL));
                map.put(TYPE,((Map)o).get(TYPE));
                resultList.add(map);
            }
        }

        return number?resultList: typeList;
    }

    /**
     * 根据参数类型调用获取公共数据方法
     * @param type
     * @return
     */
    private List<?> getDataByType(String type) {
        if (ValidatorUtil.isEmptyObj(type)) {
            return null;
        }
        List<?> list;
        switch (type) {
            // 地址
            case "cityCode":
                list = getCityCode();
                break;
            // 监测器状态
            case "state":
                list = getState();
                break;
            // 文件统计日期
            case "tableName":
                list = getTableName();
                break;
            // 文件类型
            case "fileType":
                list = getFileType();
                break;
            // 目录
            case "directory":
                list = getDirectory();
                break;
            case "dicType":
                list = DictUtils.getDicTypeList(type);
                break;
            case ALARM_POLICY_TYPE:
            case "policyType":
                list = getPolicyType(type);
                break;
            case "sys_area_type":
                list = getSysAreaType(type);
                break;
            // 命令
            case Constant.COMMAND:
                list = get(Constant.Command.values());
                break;
            // 命令状态
            case "commandState":
                list = get(Constant.CommandState.values());
                break;
            // 分组信息
            case "groupInfo":
                list = getGroupList();
                break;
            // 删除内置策略模块
            case "builtModule":
                list = getListByMap(PolicyUtils.POLICY_BUILT_IN_TYPE);
                break;
                //关键词类型带开关的类型
            case "key_ruleType_cBox":
                list = getKeyRuleTypeCBox(type);
                break;
            case "maxUploadSize":
                list = getMaxUploadSize();
                break;
            case "deviceId":
                list = getDeviceIdMap();
                break;
            case "bussinessType":
                list = getBussinessTypeList();
                break;
            case "tableNameReport":
                list =  AlarmReportRecordService.showAllTablesName();
                break;
            case "dataType":
                list = DataTypesEnum.getDataTypes();
                break;
            case Constant.STYLE_TYPE_CAMEL:
                list = getStyleType(type);
                break;
            case "sealType":
                list = getSealType(type);
                break;
            case "hash_ruleType":
                list = getHashRuleType(type);
                break;
            case "encryptionFileType":
                list = getEncryptionFileType();
                break;
            case "appProtocolType":
                list = getAppProtocolType(type);
                break;
            case Constant.LOG_TYPE:
                list = getLogType(type);
                break;
            case "trojanAttackClassType":
                list = getTrojanAttackClassType(type);
                break;
            case "attackClassType":
                list = getAttackClassType(type);
                break;
            case "malwareAttackClassType":
                list = getMalwareAttackClassType(type);
                break;
            case "ipBlacklistAttackClassType":
                list = getIpBlacklistAttackClassType(type);
                break;
            case "attackStageType":
                list = getAttackStageType(type);
                break;
            case "facilityType":
                list = getFacilityType(type);
                break;
            case "accountBlacklistType":
                list = getAccountBlacklistType(type);
                break;
            case Constant.SHARE_TYPE:
                list = getShareType(type);
                break;
            case "subscription":
                list = SubscriptionEn.getsubscrptionType();
                break;
            case "subModelList":
                list = getmodelList();
                break;
            case "netLogTableNames":
                list = getNetLogTableNames();
                break;
            case "emailTableNames":
                list = getEmailTableNames();
                break;
            case "webTableNames":
                list = getWebTableNames();
                break;
            case "fileTransport":
                list = getFileTransport();
                break;
            case "ssltableName":
                list = getSsltableName();
                break;
            case "dnsTableNames":
                list = getDnsTableName();
                break;
            case "operateTableNames":
                list = getOperateTableNames();
                break;
            case "loginTableNames":
                list = getLoginTableNames();
                break;
            case "contrilTableNames":
                list = getContrilTableNames();
                break;
            case Constant.CLASSIFICATION_TYPE:
                list = getClassificationType(type);
                break;
            case "documentStyleType":
                list = getDocumentStyleType(type);
                break;
            case Constant.STYLE_CLASSIFICATION_TYPE:
                list = getStyleClassificationType(type);
                break;
            case "filterFileType":
                list = getFilterFileType(type);
                break;
            case "protocolType":
                list = getProtocolType(type);
                break;
            case "auditType":
                list = getAuditType(type);
                break;
            case "webType":
                list = getWebType(type);
                break;
            case "dnsType":
                list = getDnsType(type);
                break;
            case "ssltlsType":
                list = getSsltlsType(type);
                break;
            case "dbType":
                list = getDbType(type);
                break;
            case "documentType":
                list = getDocumentType(type);
                break;
            case "controlType":
                list = getControlType(type);
                break;
            case "loginType":
                list = getLoginType(type);
                break;
            case "emailType":
                list = getEmailType(type);
                break;
            case Constant.MODULE:
                list = getRemoveOverStockAlarm(type);
                break;
            case "effectState":
                list = get(Constant.EffectState.values());
                break;
            case "commandType":
                list = getCommandType();
                break;
            case "expandType":
                list = getExpandType();
                break;
            case "monitorEventType":
                list = getMonitorEventType(type);
                break;
            case "event_type":
            case "event_type_jcq":
                list = getMcEventType(type);
                break;
            case "device_type":
                list = get(Constant.DeviceTypeEnum.values());
                break;
            default:
                list = DictUtils.getDictList(type);
        }
        return list;
    }

    public List<HashMap<String,String>> getCommandType(){
        SysDict maintain = sysDictService.getOne(new QueryWrapper<SysDict>().eq(TYPE,"ssh_connect"));
        return CommandType.getCommandType("1".equals(maintain.getValue()) ? "false":"true");
    }

    public List<HashMap<String,String>> getExpandType(){
        return ExpandType.getExpandType();
    }

    private List<Map<String,String>> getRemoveOverStockAlarm(String type) {
        List<Map<String,String>> list = Arrays.asList(V2SubmoduleEnum.values().clone()).stream().map(p->{
            Map<String,String> map = new HashMap<>();
            map.put(Constant.VALUE,p.getSubmodule());
            map.put(Constant.LABEL,p.getDesc());
            map.put(TYPE,type);
            return map;
        }).collect(Collectors.toList());
        return list;
    }

    public List<Map<String, String>> getContrilTableNames() {
        List<String> tablesNameList = aAlarmAppBehaviorControlV2Service.showAllTablesName();
        Collections.reverse(tablesNameList);
        List<Map<String, String>> list = new ArrayList<>();
        for (String tableName : tablesNameList) {
            Map<String, String> map = new HashMap<>(2);
            map.put(Constant.VALUE, tableName);
            map.put(Constant.LABEL, tableName.substring(32));
            list.add(map);
        }
        return list;
    }

    public List<Map<String, String>> getLoginTableNames() {
        List<String> tablesNameList = aAlarmAppBehaviorLoginV2Service.showAllTablesName();
        Collections.reverse(tablesNameList);
        List<Map<String, String>> list = new ArrayList<>();
        for (String tableName : tablesNameList) {
            Map<String, String> map = new HashMap<>(2);
            map.put(Constant.VALUE, tableName);
            map.put(Constant.LABEL, tableName.substring(30));
            list.add(map);
        }
        return list;
    }

    public List<Map<String, String>> getOperateTableNames() {
        List<String> tablesNameList = aAlarmAppBehaviorDbOperateV2Service.showAllTablesName();
        Collections.reverse(tablesNameList);
        List<Map<String, String>> list = new ArrayList<>();
        for (String tableName : tablesNameList) {
            Map<String, String> map = new HashMap<>(2);
            map.put(Constant.VALUE, tableName);
            map.put(Constant.LABEL, tableName.substring(35));
            list.add(map);
        }
        return list;
    }

    public List<Map<String, String>> getDnsTableName() {
        List<String> tablesNameList = aAlarmAppBehaviorDnsV2Service.showAllTablesName();
        Collections.reverse(tablesNameList);
        List<Map<String, String>> list = new ArrayList<>();
        for (String tableName : tablesNameList) {
            Map<String, String> map = new HashMap<>(2);
            map.put(Constant.VALUE, tableName);
            map.put(Constant.LABEL, tableName.substring(28));
            list.add(map);
        }
        return list;
    }


    public List<Map<String, String>> getSsltableName() {
        List<String> tablesNameList = aAlarmAppBehaviorSslV2Service.showAllTablesName();
        Collections.reverse(tablesNameList);
        List<Map<String, String>> list = new ArrayList<>();
        for (String tableName : tablesNameList) {
            Map<String, String> map = new HashMap<>(2);
            map.put(Constant.VALUE, tableName);
            map.put(Constant.LABEL, tableName.substring(28));
            list.add(map);
        }
        return list;
    }

    public List<Map<String, String>> getFileTransport() {
        List<String> tablesNameList = aAlarmAppBehaviorFileTransportV2Service.showAllTablesName();
        Collections.reverse(tablesNameList);
        List<Map<String, String>> list = new ArrayList<>();
        for (String tableName : tablesNameList) {
            Map<String, String> map = new HashMap<>(2);
            map.put(Constant.VALUE, tableName);
            map.put(Constant.LABEL, tableName.substring(39));
            list.add(map);
        }
        return list;
    }

    public List<Map<String, String>> getWebTableNames() {
        List<String> tablesNameList = aAlarmAppBehaviorWebV2Service.showAllTablesName();
        Collections.reverse(tablesNameList);
        List<Map<String, String>> list = new ArrayList<>();
        for (String tableName : tablesNameList) {
            Map<String, String> map = new HashMap<>(2);
            map.put(Constant.VALUE, tableName);
            map.put(Constant.LABEL, tableName.substring(28));
            list.add(map);
        }
        return list;
    }

    public List<Map<String, String>> getEmailTableNames() {
        List<String> tablesNameList = aAlarmAppBehaviorEmailV2Service.showAllTablesName();
        Collections.reverse(tablesNameList);
        List<Map<String, String>> list = new ArrayList<>();
        for (String tableName : tablesNameList) {
            Map<String, String> map = new HashMap<>(2);
            map.put(Constant.VALUE, tableName);
            map.put(Constant.LABEL, tableName.substring(30));
            list.add(map);
        }
        return list;
    }

    public List<Map<String, String>> getNetLogTableNames() {
        List<String> tablesNameList = aAlarmNetLogV2Service.showAllTablesName();
        Collections.reverse(tablesNameList);
        List<Map<String, String>> list = new ArrayList<>();
        for (String tableName : tablesNameList) {
            Map<String, String> map = new HashMap<>(2);
            map.put(Constant.VALUE, tableName);
            map.put(Constant.LABEL, tableName.substring(19));
            list.add(map);
        }
        return list;
    }

    private List<ModuleStatusVo> getmodelList(){
        List<ModuleStatusVo> moduleList = Lists.newArrayList();
        // 主模块集合
        Set<Map.Entry<String, String>> entries = Constant.MODULE_TYPE_SUB.entrySet();
        for (Map.Entry<String, String> entry : entries) {
            ModuleStatusVo moduleStatusVo = new ModuleStatusVo();
            // 模块名称
            String key = entry.getKey();
            moduleStatusVo.setName(key);
            // 名称描述
            moduleStatusVo.setDesc(entry.getValue());

            List<ModuleStatusVo> subModuleList = addSubModuleList(key);
            moduleStatusVo.setSubmodule(subModuleList);
            moduleList.add(moduleStatusVo);
        }
        return moduleList;
    }

    private static List<ModuleStatusVo> addSubModuleList(String key) {
        List<ModuleStatusVo> subModuleList = Lists.newArrayList();
        if (ModuleConstant.OBJECT_LISTEN.equals(key)) {
            ModuleStatusVo subModule = new ModuleStatusVo();
            subModule.setName(ModuleConstant.OBJECT_LISTEN);
            subModule.setDesc("目标流量审计");
            subModuleList.add(subModule);
            return subModuleList;
        }
        if ("file_filter".equals(key)) {
            ModuleStatusVo subModule = new ModuleStatusVo();
            subModule.setName("file_filter");
            subModule.setDesc("文件筛选");
            subModuleList.add(subModule);
            return subModuleList;
        }
        if ("target_ident".equals(key)) {
            Map<String, String> targentIdent = Constant.TARGET_IDENT;
            Set<String> strings = targentIdent.keySet();
            for (String string : strings) {
                ModuleStatusVo subModule = new ModuleStatusVo();
                subModule.setName(string);
                subModule.setDesc(targentIdent.get(string));
                subModuleList.add(subModule);
            }
            return subModuleList;
        }

        // 子模块配置
        List<Dict> dictList = DictUtils.getDictList(key);
        if (ValidatorUtil.isEmptyCollection(dictList)) {
            return subModuleList;
        }
        // 添加子模块

        for (Dict dict : dictList) {
            if (dict.getLabel().contains("白名单")) {
                continue;
            }
            ModuleStatusVo subModule = new ModuleStatusVo();
            subModule.setName(dict.getValue());
            subModule.setDesc(dict.getLabel());
            subModuleList.add(subModule);
        }
        return subModuleList;
    }

    private List<String> getBussinessTypeList(){
        String[] bussinessType = {"JCQ_CSSM_MB_FILE","JCQ_CSSM_SENSITIVE_FILE","JCQ_CSSM_KEYWORD_FILE","JCQ_CSSM_FILTEREDENC_FILE","CQ_CSSM_FILTEREDCOM_FILE",
                "JCQ_CSSM_FILTEREDPIC_FILE","JCQ_CSSM_LAYOUT_FILE","JCQ_GJQM_TROJAN_FILE","JCQ_GJQM_ATTACK_FILE","JCQ_GJQM_MALWARE_FILE",
                "JCQ_GJQM_ABNORMAL_FILE","JCQ_MBSJ_IP_FILE","JCQ_MBSJ_DOMAIN_FILE","JCQ_MBSJ_URL_FILE","JCQ_MBSJ_ACCOUNT_FILE",
                "JCQ_XWSJ_NETLOG_FILE","JCQ_XWSJ_APPBEHAVIOR_FILE","JCQ_CJGJ_FILE",
                "JCQ_CSSM_MB", "JCQ_CSSM_SENSITIVE", "JCQ_CSSM_KEYWORD", "JCQ_CSSM_FILTEREDENC", "JCQ_CSSM_FILTEREDCOM",
                "JCQ_CSSM_FILTEREDPIC", "JCQ_CSSM_LAYOUT", "JCQ_GJQM_TROJAN", "JCQ_GJQM_ATTACK", "JCQ_GJQM_MALWARE",
                "JCQ_GJQM_ABNORMAL", "JCQ_MBSJ_IP", "JCQ_MBSJ_DOMAIN", "JCQ_MBSJ_URL", "JCQ_MBSJ_ACCOUNT", "JCQ_TXZD_BLOCK",
                "JCQ_STATUS_BUSINESS","JCQ_CJZT","JCQ_STATUS_INFO","JCQ_STATUS_SYSTEM","ECHO_DIRECTOR_COMMAND_SYN",
                "ECHO_DIRECTOR_PLUG_SYN","ECHO_DIRECTOR_POLICY_KEYWORD","ECHO_DIRECTOR_POLICY_COMPRESS","ECHO_DIRECTOR_POLICY_ENCRYPTION","ECHO_DIRECTOR_POLICY_PICTURE",
                "ECHO_DIRECTOR_POLICY_TROJAN","ECHO_DIRECTOR_POLICY_ATTACK","ECHO_DIRECTOR_POLICY_MALWARE","ECHO_DIRECTOR_POLICY_ABNORMAL","ECHO_DIRECTOR_POLICY_ABNORMAL","ECHO_DIRECTOR_POLICY_IPLISTEN",
                "ECHO_DIRECTOR_POLICY_DNSLISTEN","ECHO_DIRECTOR_POLICY_URLLISTEN","ECHO_DIRECTOR_POLICY_ACCOUNTLISTEN","ECHO_DIRECTOR_POLICY_BLOCK","ECHO_DIRECTOR_POLICY_NETLOG",
                "ECHO_DIRECTOR_POLICY_APPBEHAVIOR","ECHO_DIRECTOR_POLICY_WEBFILTER","ECHO_DIRECTOR_POLICY_DNSFILTER","ECHO_DIRECTOR_POLICY_IPWHITELIST",
                "JCQ_AUDIT","CENTER_AUDIT",
                "CENTER_POLICY_KEYWORD","CENTER_POLICY_COMPRESS","CENTER_POLICY_ENCRYPTION","CENTER_POLICY_PICTURE","CENTER_POLICY_TROJAN",
                "CENTER_POLICY_ATTACK","CENTER_POLICY_MALWARE","CENTER_POLICY_ABNORMAL","CENTER_POLICY_IPLISTEN","CENTER_POLICY_DNSLISTEN",
                "CENTER_POLICY_URLLISTEN","CENTER_POLICY_ACCOUNTLISTEN","CENTER_POLICY_BLOCK","CENTER_POLICY_NETLOG","CENTER_POLICY_APPBEHAVIOR",
                "CENTER_POLICY_WEBFILTER","CENTER_POLICY_DNSFILTER","CENTER_POLICY_IPWHITELIST"};
        return Arrays.asList(bussinessType).stream().distinct().collect(Collectors.toList());
    }
    private List<String> getDeviceIdMap(){
        SysInfo manageId = sysInfoService.getManageId();
        List<ComDetectorDevice> list = comDetectorDeviceService.list(
                Wrappers.lambdaQuery(new ComDetectorDevice()).eq(ComDetectorDevice::getDeviceType, "01")
                        .eq(ComDetectorDevice::getPid, manageId.getValue()).select(ComDetectorDevice::getDeviceId));
        List<String> collect = list.stream().map(ComDetectorDevice::getDeviceId).collect(Collectors.toList());
        return collect;
    }

    private List<Map<String, String>> getMaxUploadSize() {
        String maxUploadSize = Constant.getDictValue("max_upload_size",jedisUtil,sysDictService);
        String size = ValidatorUtil.isEmptyObj(maxUploadSize) ? "500" : maxUploadSize;
        Map<String, String> map = new HashMap<>(2);
        map.put(Constant.VALUE, "maxUploadSize");
        map.put(Constant.LABEL, size);
        List<Map<String, String>> list = new ArrayList<>();
        list.add(map);
        return list;
    }

    public List<Map<String, String>> getListByMap(Map<String, String> sourceMap) {
        List<Map<String, String>> list = new ArrayList<>();
        Set<Map.Entry<String, String>> entries = sourceMap.entrySet();
        for (Map.Entry<String, String> entry : entries) {
            Map<String, String> map = new HashMap<>(2);
            map.put(Constant.VALUE, entry.getKey());
            map.put(Constant.LABEL, entry.getValue());
            list.add(map);
        }
        return list;
    }

    /**
     * 获取枚举列表
     * @param values
     * @param <T>
     * @return
     */
    public <T extends Constant.Type> List<Map<String, String>> get(T[] values) {
        List<Map<String, String>> list = new ArrayList<>();
        for (T t : values) {
            Map<String, String> map = new HashMap<>(2);
            map.put(Constant.VALUE, t.getType());
            map.put(Constant.LABEL, t.getDesc());
            list.add(map);
        }
        return list;
    }



    /**
     * 获取目录
     * @return
     */
    public List<Map<String, String>> getDirectory() {
        List<Dict> list = DictUtils.getDictList("directoryType");
        List<Map<String,String>> directoryType = new ArrayList<>();
        for (Dict dict: list){
            Map<String,String> map = new HashMap<>();
            map.put(Constant.VALUE,dict.getValue());
            map.put(Constant.LABEL, dict.getLabel());
            directoryType.add(map);
        }
        return directoryType;
    }

    /**
     * 获取文件类型
     * @return
     */
    public List<Map<String, String>> getFileType() {
        List<Map<String, String>> list = new ArrayList<>();
        Constant.FileType[] values = Constant.FileType.values();
        for (Constant.FileType value : values) {
            Map<String, String> map = new HashMap<>(2);
            map.put(Constant.VALUE, value.getType());
            map.put(Constant.LABEL, value.getDesc());
            list.add(map);
        }
        return list;
    }

    /**
     * 获取alarm_recorder分表表名列表
     * @return
     */
    public List<Map<String, String>> getTableName() {
        List<String> tablesNameList = alarmRecorderService.showAllTablesName();
        Collections.reverse(tablesNameList);
        List<Map<String, String>> list = new ArrayList<>();
        for (String tableName : tablesNameList) {
            Map<String, String> map = new HashMap<>(2);
            map.put(Constant.VALUE, tableName);
            map.put(Constant.LABEL, tableName.substring(15));
            list.add(map);
        }
        return list;
    }

    /**
     * 状态
     * @return
     */
    public List<Map<String, String>> getState() {
        List<Map<String, String>> list = new ArrayList<>();
        DeviceOperateStatusEnum[] values = DeviceOperateStatusEnum.values();
        for (DeviceOperateStatusEnum value : values) {
            String code = String.valueOf(value.getCode());
            Map<String, String> map = new HashMap<>(2);
            map.put(Constant.VALUE, code);
            map.put(Constant.LABEL, value.getMessage());
            list.add(map);
        }
        return list;
    }

    public List getCityCode() {
        // 取缓存
        Object cityCode = CacheUtils.get(CacheUtils.CITY_JSON);
        if (ValidatorUtil.isNotEmptyObj(cityCode)) {
            return (List<Citycode>) cityCode;
        }
        // 查数据
        List<Citycode> cityCodeList = citycodeService.getCityCode();
        // 存缓存
        CacheUtils.put(CacheUtils.CITY_JSON, cityCodeList);
        return cityCodeList;
    }


    private List<Map<String,String>> getPolicyType(final String type) {
        List<String> filterPolicyModuleList = Lists.newArrayList(V2PolicyEnum.NET_AUDIT_AUDIT_IP_WHITELIST.getSubmodule(),
                    V2PolicyEnum.NET_AUDIT_AUDIT_DOMAIN_WHITELIST.getSubmodule(),
                    V2PolicyEnum.ALARM_IP_WHITELIST.getSubmodule(),
                    V2PolicyEnum.ALARM_HASH_WHITELIST.getSubmodule(),
                    V2PolicyEnum.OBJECT_LISTEN_IP_LISTEN.getSubmodule(),
                    V2PolicyEnum.OBJECT_LISTEN_DOMAIN_LISTEN.getSubmodule()
        );
        List<Map<String,String>> list = Arrays.stream(V2PolicyEnum.values().clone())
                .filter(v2PolicyEnum -> {
                    boolean result = true;
                    if (ALARM_POLICY_TYPE.equals(type)) {
                        result = !filterPolicyModuleList.contains(v2PolicyEnum.getSubmodule());
                    }
                    return result;
                })
                .map(p->{
            Map<String,String> map = new HashMap<>();
            map.put(Constant.VALUE,p.getSubmodule());
            map.put(Constant.LABEL,p.getDesc());
            map.put(TYPE,type);
            return map;
        }).collect(Collectors.toList());
        if (ALARM_POLICY_TYPE.equals(type)) {
            Map<String,String> map1 = new HashMap<>();
            map1.put(Constant.VALUE, ModuleConstant.OBJECT_LISTEN);
            map1.put(Constant.LABEL, "目标流量审计");
            map1.put(TYPE, type);
            Map<String,String> map2 = new HashMap<>();
            map2.put(Constant.VALUE, "sensitive_file");
            map2.put(Constant.LABEL, "涉密敏感信息检测-标密文件检测");
            map2.put(TYPE, type);
            Map<String,String> map3 = new HashMap<>();
            map3.put(Constant.VALUE, "file_style");
            map3.put(Constant.LABEL, "涉密敏感信息检测-版式文件筛选");
            map3.put(TYPE, type);
            list.add(map1);
            list.add(map2);
            list.add(map3);
        }
        return list;
    }

    private List<Map<String,String>> getSysAreaType(final String type) {
        List<Map<String,String>> list = Arrays.asList(Constant.PolicySourceLevel.values().clone()).stream().filter(p-> StringUtil.isNotEmpty( p.getType())).map(p->{
            Map<String,String> map = new HashMap<>();
                map.put(Constant.VALUE,p.getType());
                map.put(Constant.LABEL, Constant.PolicySourceLevel.get(p.getType()));
                map.put(TYPE,type);
            return map;
        }).collect(Collectors.toList());
        return list;
    }

    /**
     * 获取分组列表
     * @return
     */
    private List<Map<String, String>> getGroupList() {
        List<TblGroupInfo> infoList = tblGroupInfoService.list(new QueryWrapper<TblGroupInfo>().orderByAsc("id"));
        if (ValidatorUtil.isEmptyCollection(infoList)) {
            return null;
        }
        List<Map<String, String>> list = new ArrayList<>();
        for (TblGroupInfo info : infoList) {
            Map<String, String> map = new HashMap<>(2);
            map.put(Constant.VALUE, String.valueOf(info.getId()));
            map.put(Constant.LABEL, info.getName());
            list.add(map);
        }
        return list;
    }

    /**
     * 根据开关显示关键词类型
     * showKeyword
     * @return
     */
    private List<Map<String,String>> getKeyRuleTypeCBox(String type) {
        List<Dict> list = DictUtils.getDictList("showKeyword");
        List<Dict> keyTypeList = DictUtils.getDictList("key_ruleType");
        List<Map<String,String>> cBoxList = new ArrayList<>();

        boolean showKeyworkd = true;
        if(!CollectionUtils.isEmpty(list)){
            Dict dic = list.get(0);
            //1 关闭
            if(dic!=null && "1".equals(dic.getValue())){
                showKeyworkd = false;
            }
        }

        for (Dict dict: keyTypeList
             ) {
            //0 关键字
            if((!showKeyworkd)&&"0".equals(dict.getValue())){
                continue;
            }
            Map<String,String> map = new HashMap<>();
            map.put(Constant.VALUE,dict.getValue());
            map.put(Constant.LABEL, dict.getLabel());
            map.put(TYPE,type);
            cBoxList.add(map);
        }

        return cBoxList;
    }

    private List<Map<String,String>> getStyleType(final String type) {
        List<Dict> list = DictUtils.getDictList(Constant.STYLE_TYPE_CAMEL);
        List<Map<String,String>> styleTypeList = new ArrayList<>();
        for (Dict dict: list){
            Map<String,String> map = new HashMap<>();
            map.put(Constant.VALUE,dict.getValue());
            map.put(Constant.LABEL, dict.getLabel());
            map.put(TYPE,type);
            styleTypeList.add(map);
        }
        return styleTypeList;
    }

    private List<Map<String,String>> getSealType(String type) {
        List<Dict> list = DictUtils.getDictList("sealType");
        List<Map<String,String>> sealTypeList = new ArrayList<>();
        for (Dict dict: list){
            Map<String,String> map = new HashMap<>();
            map.put(Constant.VALUE,dict.getValue());
            map.put(Constant.LABEL, dict.getLabel());
            map.put(TYPE,type);
            sealTypeList.add(map);
        }
        return sealTypeList;
    }

    private List<Map<String,String>> getHashRuleType(String type) {
        List<Dict> list = DictUtils.getDictList("hash_ruleType");
        List<Map<String,String>> hashRuleTypeList = new ArrayList<>();
        for (Dict dict: list){
            Map<String,String> map = new HashMap<>();
            map.put(Constant.VALUE,dict.getValue());
            map.put(Constant.LABEL, dict.getLabel());
            map.put(TYPE,type);
            hashRuleTypeList.add(map);
        }
        return hashRuleTypeList;
    }

    private List<FileTypeNode> getEncryptionFileType() {
        List<SysDict> list = sysDictService.list(new LambdaQueryWrapper<SysDict>()
                .select(SysDict::getId, SysDict::getParentId, SysDict::getValue, SysDict::getLabel)
                .eq(SysDict::getType, "fileType").orderByAsc(SysDict::getSort));
        List<FileTypeNode> fileTypeNodeList = Lists.newArrayList();
        for (SysDict sysDict : list) {
            FileTypeNode fileTypeNode = new FileTypeNode();
            fileTypeNode.setId(sysDict.getId().toString());
            fileTypeNode.setParentId(sysDict.getParentId());
            fileTypeNode.setType(sysDict.getType());
            fileTypeNode.setLabel(sysDict.getLabel());
            fileTypeNode.setValue(sysDict.getValue());
            fileTypeNodeList.add(fileTypeNode);
        }
        return TreeUtils.build(fileTypeNodeList,"0");
    }

    private List<Map<String,String>> getAppProtocolType(String type) {
        List<Dict> list = DictUtils.getDictList("appProtocolType");
        List<Map<String,String>> mapList = new ArrayList<>();
        for (Dict dict: list){
            Map<String,String> map = new HashMap<>();
            map.put(Constant.VALUE,dict.getValue());
            map.put(Constant.LABEL, dict.getLabel());
            map.put(TYPE,type);
            mapList.add(map);
        }
        return mapList;
    }

    private List<Map<String,String>> getLogType(String type) {
        List<Dict> list = DictUtils.getDictList(Constant.LOG_TYPE);
        List<Map<String,String>> mapList = new ArrayList<>();
        for (Dict dict: list){
            Map<String,String> map = new HashMap<>();
            map.put(Constant.VALUE,dict.getValue());
            map.put(Constant.LABEL, dict.getLabel());
            map.put(TYPE,type);
            mapList.add(map);
        }
        return mapList;
    }

    private List<Map<String,String>> getTrojanAttackClassType(String type) {
        List<Dict> list = DictUtils.getDictList("trojanAttackClassType");
        List<Map<String,String>> mapList = new ArrayList<>();
        for (Dict dict: list){
            Map<String,String> map = new HashMap<>();
            map.put(Constant.VALUE,dict.getValue());
            map.put(Constant.LABEL, dict.getLabel());
            map.put(TYPE,type);
            mapList.add(map);
        }
        return mapList;
    }

    private List<Map<String,String>> getAttackClassType(String type) {
        List<Dict> list = DictUtils.getDictList("attackClassType");
        List<Map<String,String>> mapList = new ArrayList<>();
        for (Dict dict: list){
            Map<String,String> map = new HashMap<>();
            map.put(Constant.VALUE,dict.getValue());
            map.put(Constant.LABEL, dict.getLabel());
            map.put(TYPE,type);
            mapList.add(map);
        }
        return mapList;
    }

    private List<Map<String,String>> getMalwareAttackClassType(String type) {
        List<Dict> list = DictUtils.getDictList("malwareAttackClassType");
        List<Map<String,String>> mapList = new ArrayList<>();
        for (Dict dict: list){
            Map<String,String> map = new HashMap<>();
            map.put(Constant.VALUE,dict.getValue());
            map.put(Constant.LABEL, dict.getLabel());
            map.put(TYPE,type);
            mapList.add(map);
        }
        return mapList;
    }

    @PostMapping("/exit")
    public Result getSession(){
        return new Result(ResultStatus.SUCCESS.getCode());
    }

    private List<Map<String,String>> getIpBlacklistAttackClassType(String type) {
        List<Dict> list = DictUtils.getDictList("ipBlacklistAttackClassType");
        List<Map<String,String>> mapList = new ArrayList<>();
        for (Dict dict: list){
            Map<String,String> map = new HashMap<>();
            map.put(Constant.VALUE,dict.getValue());
            map.put(Constant.LABEL, dict.getLabel());
            map.put(TYPE,type);
            mapList.add(map);
        }
        return mapList;
    }

    private List<Map<String,String>> getAttackStageType(String type) {
        List<Dict> list = DictUtils.getDictList("attackStageType");
        List<Map<String,String>> mapList = new ArrayList<>();
        for (Dict dict: list){
            Map<String,String> map = new HashMap<>();
            map.put(Constant.VALUE,dict.getValue());
            map.put(Constant.LABEL, dict.getLabel());
            map.put(TYPE,type);
            mapList.add(map);
        }
        return mapList;
    }

    private List<Map<String,String>> getFacilityType(String type) {
        List<Dict> list = DictUtils.getDictList("facilityType");
        List<Map<String,String>> facilityType = new ArrayList<>();
        for (Dict dict: list){
            Map<String,String> map = new HashMap<>();
            map.put(Constant.VALUE,dict.getValue());
            map.put(Constant.LABEL, dict.getLabel());
            map.put(TYPE,type);
            facilityType.add(map);
        }
        return facilityType;
    }

    private List<Map<String,String>> getAccountBlacklistType(String type) {
        List<Dict> list = DictUtils.getDictList("accountBlacklistType");
        List<Map<String,String>> accountBlacklistType = new ArrayList<>();
        for (Dict dict: list){
            Map<String,String> map = new HashMap<>();
            map.put(Constant.VALUE,dict.getValue());
            map.put(Constant.LABEL, dict.getLabel());
            map.put(TYPE,type);
            accountBlacklistType.add(map);
        }
        return accountBlacklistType;
    }

    private List<Map<String,String>> getShareType(String type) {
        List<Dict> list = DictUtils.getDictList(Constant.SHARE_TYPE);
        List<Map<String,String>> shareType = new ArrayList<>();
        for (Dict dict: list){
            Map<String,String> map = new HashMap<>();
            map.put(Constant.VALUE,dict.getValue());
            map.put(Constant.LABEL, dict.getLabel());
            map.put(TYPE,type);
            shareType.add(map);
        }
        return shareType;
    }

    private List<Map<String,String>> getClassificationType(String type){
        List<Dict> list = DictUtils.getDictList(Constant.CLASSIFICATION_TYPE);
        List<Map<String,String>> classificationType = new ArrayList<>();
        for (Dict dict: list){
            Map<String,String> map = new HashMap<>();
            map.put(Constant.VALUE,dict.getValue());
            map.put(Constant.LABEL, dict.getLabel());
            map.put(TYPE,type);
            classificationType.add(map);
        }
        return classificationType;
    }

    private List<Map<String,String>> getDocumentStyleType(String type){
        List<Dict> list = DictUtils.getDictList("documentStyleType");
        List<Map<String,String>> documentStyleType = new ArrayList<>();
        for (Dict dict: list){
            Map<String,String> map = new HashMap<>();
            map.put(Constant.VALUE,dict.getValue());
            map.put(Constant.LABEL, dict.getLabel());
            map.put(TYPE,type);
            documentStyleType.add(map);
        }
        return documentStyleType;
    }

    private List<Map<String,String>> getStyleClassificationType(String type){
        List<Dict> list = DictUtils.getDictList(Constant.STYLE_CLASSIFICATION_TYPE);
        List<Map<String,String>> styleClassificationType = new ArrayList<>();
        for (Dict dict: list){
            Map<String,String> map = new HashMap<>();
            map.put(Constant.VALUE,dict.getValue());
            map.put(Constant.LABEL, dict.getLabel());
            map.put(TYPE,type);
            styleClassificationType.add(map);
        }
        return styleClassificationType;
    }

    private List<Map<String,String>> getFilterFileType(String type) {
        List<Dict> list = DictUtils.getDictList("filterFileType");
        List<Map<String,String>> filterFileType = new ArrayList<>();
        for (Dict dict: list){
            Map<String,String> map = new HashMap<>();
            map.put(Constant.VALUE,dict.getValue());
            map.put(Constant.LABEL, dict.getLabel());
            map.put(TYPE,type);
            filterFileType.add(map);
        }
        return filterFileType;
    }

    private List<Map<String,String>> getProtocolType(String type) {
        List<Dict> list = DictUtils.getDictList("protocolType");
        List<Map<String,String>> protocolType = new ArrayList<>();
        for (Dict dict: list){
            Map<String,String> map = new HashMap<>();
            map.put(Constant.VALUE,dict.getValue());
            map.put(Constant.LABEL, dict.getLabel());
            map.put(TYPE,type);
            protocolType.add(map);
        }
        return protocolType;
    }

    private List<Map<String,String>> getAuditType(String type) {
        List<Dict> list = DictUtils.getDictList(Constant.LOG_TYPE);
        List<Map<String,String>> getAuditType = new ArrayList<>();
        for (Dict dict: list){
            Map<String,String> map = new HashMap<>();
            map.put(Constant.VALUE,dict.getValue());
            map.put(Constant.LABEL, dict.getLabel());
            map.put(TYPE,type);
            getAuditType.add(map);
        }
        return getAuditType;
    }

    private List<Map<String,String>> getWebType(String type) {
        List<Dict> list = DictUtils.getDictList("webType");
        List<Map<String,String>> webType = new ArrayList<>();
        for (Dict dict: list){
            Map<String,String> map = new HashMap<>();
            map.put(Constant.VALUE,dict.getValue());
            map.put(Constant.LABEL, dict.getLabel());
            map.put(TYPE,type);
            webType.add(map);
        }
        return webType;
    }

    private List<Map<String,String>> getDnsType(String type) {
        List<Dict> list = DictUtils.getDictList("dnsType");
        List<Map<String,String>> dnsType = new ArrayList<>();
        for (Dict dict: list){
            Map<String,String> map = new HashMap<>();
            map.put(Constant.VALUE,dict.getValue());
            map.put(Constant.LABEL, dict.getLabel());
            map.put(TYPE,type);
            dnsType.add(map);
        }
        return dnsType;
    }

    private List<Map<String,String>> getSsltlsType(String type) {
        List<Dict> list = DictUtils.getDictList("ssltlsType");
        List<Map<String,String>> ssltlsType = new ArrayList<>();
        for (Dict dict: list){
            Map<String,String> map = new HashMap<>();
            map.put(Constant.VALUE,dict.getValue());
            map.put(Constant.LABEL, dict.getLabel());
            map.put(TYPE,type);
            ssltlsType.add(map);
        }
        return ssltlsType;
    }

    private List<Map<String,String>> getDbType(String type) {
        List<Dict> list = DictUtils.getDictList("dbType");
        List<Map<String,String>> dbType = new ArrayList<>();
        for (Dict dict: list){
            Map<String,String> map = new HashMap<>();
            map.put(Constant.VALUE,dict.getValue());
            map.put(Constant.LABEL, dict.getLabel());
            map.put(TYPE,type);
            dbType.add(map);
        }
        return dbType;
    }

    private List<Map<String,String>> getDocumentType(String type) {
        List<Dict> list = DictUtils.getDictList("documentType");
        List<Map<String,String>> documentType = new ArrayList<>();
        for (Dict dict: list){
            Map<String,String> map = new HashMap<>();
            map.put(Constant.VALUE,dict.getValue());
            map.put(Constant.LABEL, dict.getLabel());
            map.put(TYPE,type);
            documentType.add(map);
        }
        return documentType;
    }

    private List<Map<String,String>> getControlType(String type) {
        List<Dict> list = DictUtils.getDictList("controlType");
        List<Map<String,String>> controlType = new ArrayList<>();
        for (Dict dict: list){
            Map<String,String> map = new HashMap<>();
            map.put(Constant.VALUE,dict.getValue());
            map.put(Constant.LABEL, dict.getLabel());
            map.put(TYPE,type);
            controlType.add(map);
        }
        return controlType;
    }

    private List<Map<String,String>> getLoginType(String type) {
        List<Dict> list = DictUtils.getDictList("loginType");
        List<Map<String,String>> loginType = new ArrayList<>();
        for (Dict dict: list){
            Map<String,String> map = new HashMap<>();
            map.put(Constant.VALUE,dict.getValue());
            map.put(Constant.LABEL, dict.getLabel());
            map.put(TYPE,type);
            loginType.add(map);
        }
        return loginType;
    }

    private List<Map<String,String>> getEmailType(String type) {
        List<Dict> list = DictUtils.getDictList("emailType");
        List<Map<String,String>> emailType = new ArrayList<>();
        for (Dict dict: list){
            Map<String,String> map = new HashMap<>();
            map.put(Constant.VALUE,dict.getValue());
            map.put(Constant.LABEL, dict.getLabel());
            map.put(TYPE,type);
            emailType.add(map);
        }
        return emailType;
    }

    private List<Map<String,String>> getMonitorEventType(String type){
        List<Dict> list = DictUtils.getDictList("monitorEventType");
        List<Map<String,String>> monitorEventType = new ArrayList<>();
        for (Dict dict: list){
            Map<String,String> map = new HashMap<>();
            map.put(Constant.VALUE,dict.getValue());
            map.put(Constant.LABEL, dict.getLabel());
            map.put(TYPE,type);
            monitorEventType.add(map);
        }
        return  monitorEventType;
    }

    private List<Map<String,String>> getMcEventType(String type) {
        String serviceName = "";
        switch (type) {
            case "event_type":
                serviceName = "mc";
                break;
            case "event_type_jcq":
                serviceName = "jcq";
                break;
            default:
        }

        List<String> eventList = operateTypeFactory.getService(serviceName).getEventList();
        List<Map<String,String>> list = new ArrayList<>();
        for (String value : eventList) {
            Map<String, String> map = new HashMap<>();
            map.put(Constant.VALUE, value);
            map.put(Constant.LABEL, value);
            map.put(TYPE, type);
            list.add(map);
        }
        return list;
    }

    /**
     * 查询操作类型列表
     *
     * @return
     */
    @RequestMapping(value = "selectOperateTypeList")
    public Result selectOperateTypeList(@RequestBody TypeVo typeVo) {
        List<String> list = operateTypeFactory.getService(typeVo.getDescription()).getOperateList(typeVo.getEventType());
        return new Result(list);
    }
}
